package com.abth.douyin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.abth.douyin.domain.DouyinShop;
import com.abth.douyin.service.IDouyinShopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抖音门店Controller
 * 
 * @author abingtech
 * @date 2025-09-04
 */
@RestController
@RequestMapping("/douyin/shop")
public class DouyinShopController extends BaseController
{
    @Autowired
    private IDouyinShopService douyinShopService;

    /**
     * 查询抖音门店列表
     */
    @PreAuthorize("@ss.hasPermi('douyin:shop:list')")
    @GetMapping("/list")
    public TableDataInfo list(DouyinShop douyinShop)
    {
        startPage();
        List<DouyinShop> list = douyinShopService.selectDouyinShopList(douyinShop);
        return getDataTable(list);
    }

    /**
     * 导出抖音门店列表
     */
    @PreAuthorize("@ss.hasPermi('douyin:shop:export')")
    @Log(title = "抖音门店", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DouyinShop douyinShop)
    {
        List<DouyinShop> list = douyinShopService.selectDouyinShopList(douyinShop);
        ExcelUtil<DouyinShop> util = new ExcelUtil<DouyinShop>(DouyinShop.class);
        util.exportExcel(response, list, "抖音门店数据");
    }

    /**
     * 获取抖音门店详细信息
     */
    @PreAuthorize("@ss.hasPermi('douyin:shop:query')")
    @GetMapping(value = "/{poiId}")
    public AjaxResult getInfo(@PathVariable("poiId") String poiId)
    {
        return success(douyinShopService.selectDouyinShopByPoiId(poiId));
    }

    /**
     * 新增抖音门店
     */
    @PreAuthorize("@ss.hasPermi('douyin:shop:add')")
    @Log(title = "抖音门店", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DouyinShop douyinShop)
    {
        return toAjax(douyinShopService.insertDouyinShop(douyinShop));
    }

    /**
     * 修改抖音门店
     */
    @PreAuthorize("@ss.hasPermi('douyin:shop:edit')")
    @Log(title = "抖音门店", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DouyinShop douyinShop)
    {
        return toAjax(douyinShopService.updateDouyinShop(douyinShop));
    }

    /**
     * 删除抖音门店
     */
    @PreAuthorize("@ss.hasPermi('douyin:shop:remove')")
    @Log(title = "抖音门店", businessType = BusinessType.DELETE)
	@DeleteMapping("/{poiIds}")
    public AjaxResult remove(@PathVariable String[] poiIds)
    {
        return toAjax(douyinShopService.deleteDouyinShopByPoiIds(poiIds));
    }
}
